import Api from '@/api/system/manager'
import i18n from "@/lang/index";
const modalConfig = {
  pageName: "sys:user",
  dialog: {
    title: i18n.global.t("title.14"),
    width: 800,
    appendToBody: true,
    draggable: true,
    labelWidth: "auto",
  },
  formAction: (data) => {
    console.log("add", data);
    return new Promise((resolve, reject) => {
      Api.add(data).then(s => {
        console.log(s);
        resolve(s)
      }).catch(e => {
        reject(e)
      })
    });
  },
  formItems: [
    {
      type: "input",
      label: i18n.global.t("form.6"),
      prop: "email",
      attrs: {
        placeholder: i18n.global.t("hint.3"),
      },
    },
    {
      type: "input",
      label: i18n.global.t("form.1"),
      prop: "name",
      attrs: {
        placeholder: i18n.global.t("hint.4"),
      },
    },
    {
      type: "input",
      label: i18n.global.t("form.50"),
      prop: "username",
      attrs: {
        placeholder: i18n.global.t("hint.72"),
      },
    },
    {
      type: "input",
      label: i18n.global.t("form.7"),
      prop: "password",
      attrs: {
        placeholder: i18n.global.t("hint.6"),
      }
    },
    {
      type: "radio",
      label: i18n.global.t("form.47"),
      prop: "is_super",
      options: [
        { label: i18n.global.t("status.2"), value: false },
        { label: i18n.global.t("status.1"), value: true },
      ],
      initialValue: false,
    },
    {
      type: "custom",
      label: i18n.global.t("form.49"),
      prop: "roles",
      attrs: {
        placeholder: i18n.global.t("hint.73"),
      },
    },
    {
      type: "input",
      label: i18n.global.t("form.46"),
      prop: "remark",
      attrs: {
        placeholder: i18n.global.t("hint.71"),
      },
    }, {
      type: "select",
      label: i18n.global.t("form.48"),
      prop: "status",
      attrs: {
        multiple: false,
      },
      options: [
        { label: i18n.global.t("status.27"), value: 'active' },
        { label: i18n.global.t("status.28"), value: 'inactive' },
      ],
      initialValue: 'active',
    },
  ],
  formRules: {
    email: [{ required: true, message: i18n.global.t("hint.3"), trigger: "blur" }],
    name: [{ required: true, message: i18n.global.t("hint.4"), trigger: "blur" }],
    password: [{ required: true, message: i18n.global.t("hint.6"), trigger: "blur" }],
    is_super: [{ required: true, message: i18n.global.t("form.47"), trigger: "blur" }],
    status: [{ required: true, message: i18n.global.t("hint.71"), trigger: "blur" }],
    roles: [{ required: true, message: i18n.global.t("hint.73"), trigger: "blur" }],
    username: [{ required: true, message: i18n.global.t("hint.72"), trigger: "blur" }]
  },
};

export default modalConfig;
